<%--
  Created by IntelliJ IDEA.
  User: ENEN
  Date: 2023/12/27
  Time: 19:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/resources/css/font.css">
    <link rel="stylesheet" href="/resources/css/xadmin.css">
    <script src="/resources/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/resources/js/xadmin.js"></script>
</head>
<body>
<%--<form class="layui-form" action="/dept/deptAdd">--%>
<%--    <label class="layui-form-label">部门编号</label>--%>
<%--    <input type="text" name="id" required lay-verify="required" placeholder="请输入部门编号" autocomplete="off" class="layui-input">--%>
<%--    <br>--%>
<%--    <label class="layui-form-label">部门名称</label>--%>
<%--    <input type="text" name="deptName" required lay-verify="required" placeholder="请输入部门名称" autocomplete="off" class="layui-input">--%>
<%--    <br>--%>
<%--    <label class="layui-form-label">部门职责</label>--%>
<%--    <br>--%>
<%--    <div class="layui-input-block">--%>
<%--        <textarea name="deptJob" placeholder="请输入内容" class="layui-textarea" style="width: 238px; height: 80px"></textarea>--%>
<%--    </div>--%>
<%--    <div class="layui-form-item">--%>
<%--        <div class="layui-input-block">--%>
<%--            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>--%>
<%--            <button type="reset" class="layui-btn layui-btn-primary">重置</button>--%>
<%--        </div>--%>
<%--    </div>--%>
<%--</form>--%>
<form class="layui-form" lay-filter="editForm">
    <div class="layui-form-item">
        <label class="layui-form-label">ID：</label>
        <div class="layui-input-block">
            <input  type="text" name="id" lay-verify="required" autocomplete="off" placeholder="请输入部门id" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门名称：</label>
        <div class="layui-input-block">
            <input type="text" name="deptName" lay-verify="required" autocomplete="off" placeholder="请输入部门名称" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门职责：</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" id="desc" name="deptJob" class="layui-textarea"></textarea>
        </div>
    </div>
    <!-- 其他表单项 -->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            $.ajax({
                url:"/dept/deptAdd",
                type:"post",
                data:JSON.stringify(data.field),
                //告诉jquery，不要处理我的数据
                processData:false,
                //告诉jquery，不要设置我的content-type请求头
                contentType:"application/json",
                success:function (res){
                    if(res.code==200){
                        layer.msg(res.msg);
                        xadmin.close();
                        xadmin.father_reload();
                    }else{
                        layer.msg(res.msg);
                    }
                }
            })

            return false;
        });
    });
</script>
